function graph = graph(numd,nume)    
    if numd > 600
        error('too many vertices!');
    elseif nume > 8
        error('too many edge!');
    end
    edgeid = 0;
    graph = zeros(numd,numd);
    for i = 1:numd
        numee = 1+floor(nume*rand()); 
        for j = 1:numd
            if sum(graph(i,:) ~= 0) >= numee
               break; 
            end
            weight = floor(21*rand());
            locate = 1+floor(numd*rand()); 
            while graph(i,locate) ~= 0
                locate = 1+floor(numd*rand()); 
            end
            graph(i,locate) = weight;
        end
    end
    f = fopen('graph.csv','w');
    for i = 1:numd
        for j = 1:numd
            if graph(i,j) ~= 0
                fprintf(f,'%d,%d,%d,%d\n',edgeid,i,j,graph(i,j));
                edgeid = edgeid + 1;
            end
        end
    end
    fclose(f);
%     w=floor(sqrt(numd));       
%     h=floor(numd/w);        
%     x=[];
%     y=[];
%     for i=1:h           %使产生的随机点有其范围，使显示分布的更广
%         for j=1:w
%             x=[x 10*rand(1)+(j-1)*10];
%             y=[y 10*rand(1)+(i-1)*10];
%         end
%     end
%     ed=numd-h*w;
%     for i=1:ed
%        x=[x 10*rand(1)+(i-1)*10]; 
%        y=[y 10*rand(1)+h*10];
%     end
%     plot(x,y,'ro');  
%     
%     title('网络拓扑图'); 
%     for i=1:numd
%         for j=1:numd
%             if graph(i,j)~=0
%                 c=num2str(graph(i,j));                      %将A中的权值转化为字符型              
% %                 text((x(i)+x(j))/2,(y(i)+y(j))/2,c,'Fontsize',10);  %显示边的权值
%                 line([x(i) x(j)],[y(i) y(j)]);
%             end
%             text(x(i),y(i),num2str(i),'Fontsize',14,'color','r');   %显示点的序号            
%             hold on;
%         end
%     end  
    